#pragma once
/// Copyright 2012, Alex Averian, Yonan Research
/// Released under BSD Licence


#include <Wincodec.h>

namespace micro
{
namespace directx
{

enum EImageType
{
    TypeBitmap,
    TypeJpeg,
    TypePng,
    TypeTiff,
    TypeGif

};

class QWic
{
public:


    //fabrica e deschisa pana se inchide programul
    static HRESULT GetGlobalFactory( IWICImagingFactory ** factory );


    //fabrica e deschisa local pana la release
    static HRESULT GetLocalFactory( IWICImagingFactory ** factory );

    static HRESULT CreateBitmapSourceFromFile( LPCTSTR path,
            unsigned int destWidth, unsigned int destHeight,
            IWICBitmapSource ** wicBitmapSource );

    static HRESULT CreateBitmapSourceFromResource(
        LPCTSTR resourceName,  LPCTSTR resourceType,
        unsigned int desWidth, unsigned int destHeight,
        IWICBitmapSource ** wicBitmapSource );

    static HRESULT CreateBitmapFromBitmapSource( IWICBitmapSource * source, HBITMAP & bitmap );
    static HRESULT CreateBitmapFromFile( LPCTSTR path,  HBITMAP & bitmap, int nWidth = 0, int nHeight = 0 );
    static HRESULT CreateBitmapFromResource( LPCTSTR resourceName,  LPCTSTR resourceType,  HBITMAP & bitmap, int nWidth = 0, int nHeight = 0 );


public://save
    static bool SaveImage( QBitmap & bmp,  QString & filePath, EImageType format = TypeJpeg );


//
//     static HRESULT DecodeImageFromThumbCache(
//         IShellItem* shellItem,
//         ID2D1RenderTarget* renderTarget,
//         unsigned int thumbnailSize,
//         ID2D1Bitmap** bitmap
//     );
//
//
//
private:
    QWic() {};
    ~QWic() {};
};



}
} //micro
